<div id="chat" ng-if="if_open_chat">
    <div ng-class="isSmart?'chat-pos-s h-auto-xs':'chat-pos h-auto-s'"
         class="app-aside-right pos-fix w-xxl w-auto-xs bg-white b-l animated fadeInRight" ng-click="clickChatWindow()">
        <div class="chat-friend-list">
            <div class="friend-search">
                <input type="text" placeholder="查找好友" class="search"
                       ng-model="myfilter">
            </div>
            <div class="chat-friends" style="border-top: .1px solid #999;border-bottom: .1px solid #999;">
                <div class="friendlist"
                     ng-repeat="model in notes.list | filter:{userName:myfilter}"
                     ng-click="loadFriendChats(model.userId, model.user, $index);"
                     ng-class="model.userId == friendId?'bg-white':'bg-color'">
                    <a class="font-bold">
                    <span class="badge btn-danger noreadcount" ng-if="model.noReadMessages>0">
                        {{ model.noReadMessages }}
                    </span>
                        <i class="thumb-xxs"><img ng-src="{{ model.pic }}" class="r r-2x"></i>
                        <span class="friend-name">{{ model.userName }}</span>
                    </a>
                    <i ng-if="model.userId>0" class="glyphicon glyphicon-remove-circle deletebtn"
                       ng-click="openDeleteFriend(model.userId, $event, $index)"></i>
                </div>
                <span style="color:red;margin-left:30px" ng-if="notes.list.length < 1">暂无好友</span>
            </div>
            <div class="add-friend">
                <div style="float:left;width:50%;text-align: center">
                    <a style="padding: 2px 10px;" class="btn btn-info btn-xs" title="添加好友"
                       ng-click="openFriendList()">
                        <i class="iconfont icon-tianjiahaoyou"></i>
                    </a>
                </div>
                <div style="float:left;width:50%;text-align: center">
                    <a style="padding: 2px 10px;" class="btn btn-warning btn-xs" title="找医助"
                       ng-click="openMedicalList()">
                        <i class="iconfont icon-yixun"></i>
                    </a>
                </div>
            </div>
        </div>
        <div style="float: left;" class="vbox">
            <div class="wrapper-ssm b-b b-t b-light">
                <div class="pull-right">
                    <a href class="text-muted text-md" ng-click="closeChat()">
                        <i class="icon-close"></i>
                    </a>
                </div>
                <span style="cursor: pointer;"
                      ng-click="open({ templateUrl: 'openUserInfoo.html'}, friendInfo, 'friendInfo')">{{ choosenUserName }}</span>
            </div>
            <div class="row-row">
                <div class="cell">
                    <div class="cell-inner wrapper-sm">
                        <!-- chat list -->
                        <div ng-if="loadingHistory" style="text-align: center;margin-bottom: 5px;">
                            <span style="color:white;background-color: red;padding:3px;border-radius:3px;">
                                <bold>正在加载数据...</bold>
                            </span>
                        </div>
                        <div ng-if="noMore" style="text-align: center;margin-bottom: 5px;">
                            <span style="background-color: red;padding:3px;border-radius:3px;">
                                <bold>已无更多</bold>
                            </span>
                        </div>
                        <div class="m-b" ng-repeat="friendMsg in friendMsgs">
                            <div ng-if="friendMsg.fromId != currentUser.userId">
                                <div class="text-muted text-center"
                                     ng-if="friendMsg.time-friendMsg.priorTime>60000">
                                    <span ng-if="friendMsg.time<currentYear">{{friendMsg.time | date:'yyyy-'}}</span>
                                    <span ng-if="friendMsg.time<currentDate">{{friendMsg.time | date:'MM-dd'}}</span>
                                    <span>{{friendMsg.time | date:'HH:mm'}}</span>
                                </div>
                                <div style="float:left;" ng-if="friendMsg.chatType.chat_Type != 'system'">
                                    <img style="width: 30px; height: 30px; border-radius: 5px;"
                                         ng-src="{{friendMsg.fromUserPic}}" alt="">
                                </div>
                                <div class="chatContent"
                                     ng-class="friendMsg.chatType.chat_Type =='system'?'system-style':'content-left'">
                                    <span class="contentArrow l b-r-color"
                                          ng-if="friendMsg.chatType.chat_Type != 'system'"></span>
                                    <span class="contentText" ng-bind-html="friendMsg.cnContent"></span>
                                </div>
                                <div style="clear: both;"></div>
                                <div style="text-align: center;font-size: 12px">
                                    <span ng-if="friendMsg.chatActions != null"
                                          ng-repeat="chatAction in friendMsg.chatActions">
                                        <span class="btn btn-{{chatAction.type}}"
                                              style="width: 50px; height: 20px; padding: 0 10px;"
                                              ng-click="chatAct(chatAction.uri)">{{chatAction.cnTitle}}
                                        </span>
                                    </span>
                                    <span ng-if="friendMsg.cnProcessed != null">{{friendMsg.cnProcessed}}</span>
                                </div>
                            </div>

                            <div ng-if="friendMsg.fromId == currentUser.userId">
                                <div class="text-muted text-center" ng-if="friendMsg.time-friendMsg.priorTime>60000">
                                    <span ng-if="friendMsg.time<currentYear">{{friendMsg.time | date:'yyyy-'}}</span>
                                    <span ng-if="friendMsg.time<currentDate">{{friendMsg.time | date:'MM-dd'}}</span>
                                    <span>{{friendMsg.time | date:'HH:mm'}}</span>
                                </div>
                                <div style="float: right;" ng-if="friendMsg.chatType.chat_Type != 'system'">
                                    <img style="width: 30px; height: 30px;border-radius:5px;"
                                         ng-src="{{friendMsg.fromUserPic}}" alt="">
                                </div>
                                <div class="chatContent"
                                     ng-class="friendMsg.chatType.chat_Type == 'system'?'system-style':'content-right'">
                                    <span class="contentArrow r b-l-color"
                                          ng-if="friendMsg.chatType.chat_Type != 'system'"></span>
                                    <span class="contentText" ng-bind-html="friendMsg.cnContent"></span>
                                    <img style="position: absolute; left: -22px; top: 33%;" ng-if="!friendMsg.time"
                                         height="17" src="./images/sending.gif" alt="">
                                </div>
                                <div style="clear: both;"></div>
                                <div style="text-align: center;font-size: 12px">
                                    <span ng-if="friendMsg.cnProcessed != null">{{friendMsg.cnProcessed}}</span>
                                </div>
                            </div>
                        </div>
                        <!-- / chat list -->
                    </div>
                </div>
            </div>
            <div class="wrapper-xs b-t b-light" ng-if="notes.list.length > 0">
                <div ng-if="notes.ifShowMore">
                    <div style="margin-bottom:5px;">
                        <i ng-click="sendPatient()" title="分享病例" style="margin:0px 10px;cursor:pointer;"
                           class="fa fa-lg fa-file"></i>
                        <i ng-click="sendImg()" title="发送图片" style="margin:0px 10px;cursor:pointer;"
                           class="fa fa-lg fa-image"></i>
                        <i ng-click="sendVioce()" title="语音" style="margin:0px 10px;cursor:pointer;"
                           class="fa fa-lg fa-microphone"></i>
                        <i ng-click="openQukMsg($event)" title="快捷回复" style="margin:0px 10px;cursor:pointer;font-size:19px;"
                           class="fa-lg iconfont icon-icon-test"></i>
                        <i data-toggle="modal" title="清除聊天记录" style="margin:0px 10px;cursor:pointer;"
                           class="fa fa-lg fa-trash-o" data-target=".model-clearMessage"></i>
                    </div>
                    <div style="width: 100%;border-bottom:1px solid #eee;margin-bottom:5px;"></div>
                </div>
                <form class="m-b-none" name="form">
                    <div class="input-group item">
                        <ul id="quk_Msg_List" ng-if="notes.showQukMsgs">
                            <li>提示：鼠标点击下方内容即可发送快捷消息！</li>
                            <li style="cursor:pointer;" ng-repeat="qukMsg in qukMsgList" ng-click="sendMessage(qukMsg)">{{$index + 1 + '、' + qukMsg}}</li>
                        </ul>
                        <input id="sendMsg" type="text" class="form-control" name="send" ng-model="notes.content"
                               autocomplete="off">
                        <span class="input-group-btn" ng-click="sendMessage('', $event)">
                            <button class="btn btn-default">发送</button>
                        </span>
                        <i ng-class="notes.ifShowMore?'text-deep':'text-gray'"
                           class="show-more glyphicon glyphicon-th glyphicon-" ng-click="notes.ifShowMore = !notes.ifShowMore;$event.stopPropagation()"></i>
                    </div>
                </form>
            </div>
        </div>
        <div style="clear: both;"></div>
    </div>
</div>

<div class="modal fade prompt-del-frd" tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel">
    <div class="modal-dialog modal-sm" role="document">
        <div class="modal-content">
            <div class="modal-body">
                确定要删除该好友？
            </div>
            <div class="modal-footer">
                <button class="btn btn-danger" ng-click="deleteFriend()">删除</button>
                <button class="btn btn-default" data-dismiss="modal">取消</button>
            </div>
        </div>
    </div>
</div>
<div class="modal fade model-clearMessage" tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel">
    <div class="modal-dialog modal-sm" role="document">
        <div class="modal-content">
            <div class="modal-body">
                确定要删除与该好友的聊天记录吗？
            </div>
            <div class="modal-footer">
                <button class="btn btn-danger" ng-click="clearMessage()">删除</button>
                <button class="btn btn-default" data-dismiss="modal">取消</button>
            </div>
        </div>
    </div>
</div>
<script type="text/ng-template" id="openUserInfoo.html">
    <div ng-include="'views/system/user_detail.html?tmp=2'"></div>
</script>

<script type="text/ng-template" id="friendListModal.html">
    <div class="panel panel-default" style="margin-bottom:0;">
        <div class="bg-light lter b-b wrapper-sm">
            <button type="button" class="close" ng-click="cancel()">
                <span class="icon icon-close" aria-hidden="true"></span>
            </button>
            <h1 class="m-n font-thin h3">
                <span class="font-bold" translate="business.accumulation.addFriend">add friend</span>
            </h1>
        </div>
        <div>
            <div class="btn-group m-t-sm col-md-8">
                <div class="input-group" ng-class="isSmart?'col-xs-12':''">
                    <input type="text" class="form-control" ng-model="addFriend.like"
                           placeholder="{{ (selectLang == 'English') ? 'enter keywords' : '\u8bf7\u8f93\u5165\u5173\u952e\u5b57' }}">
                    <span class="input-group-btn">
                    <button class="btn btn-success" ng-click="filterFriend()">
                        <span translate="business.navtitle.search_patient"></span>
                    </button>
                </span>
                </div>
            </div>
            <div class="wrapper-xs">
                <table class="table table-striped b-t b-light">
                    <tr class="panel-heading">
                        <th><span class="font-bold" translate="common.number">No.</span></th>
                        <th ng-if="!isSmart"><span class="font-bold" translate="user.username">Username</span></th>
                        <th><span class="font-bold" translate="user.realname">Real Name</span></th>
                        <th ng-if="!isSmart"><span class="font-bold" translate="user.gender">gender</span></th>
                        <th ng-if="!isSmart"><span class="font-bold" translate="user.mobilephone">Mobile</span></th>
                        <th ng-if="!isSmart"><span class="font-bold" translate="user.hosp"></span></th>
                        <th><span class="font-bold" translate="common.operate">Operate</span></th>
                    </tr>
                    <tr ng-repeat="friendDetail in addFriend.FriendsList">
                        <td style="padding:2px 10px;vertical-align:middle">{{(addFriend.pageNo-1) * addFriend.pageSize +
                            $index + 1}}
                        </td>
                        <td ng-if="!isSmart" style="padding:2px 10px;vertical-align:middle">{{friendDetail.userName}}
                        </td>
                        <td style="padding:2px 10px;vertical-align:middle">{{friendDetail.realName}}</td>
                        <td ng-if="!isSmart" style="padding:2px 10px;vertical-align:middle"><span
                                translate="{{'user.gender.' + friendDetail.gender}}"></span></td>
                        <td ng-if="!isSmart" style="padding:2px 10px;vertical-align:middle">
                            {{friendDetail.mobile_Phone}}
                        </td>
                        <td ng-if="!isSmart" style="padding:2px 10px;vertical-align:middle">{{selectLang == 'English' ?
                            friendDetail._doctor._hosp.hosp_En_Name : friendDetail._doctor._hosp.hosp_Cn_Name}}
                        </td>
                        <td style="padding:2px 10px;vertical-align:middle">
                            <button class="btn btn-primary btn-xs"
                                    ng-click="open({ templateUrl: 'views/system/user_detail.html?tmp=2'}, {{ friendDetail }} )">
                                详情
                            </button>
                            <button class="btn btn-success btn-xs" ng-click="addFriends(friendDetail.userId)">加好友
                            </button>
                            <button class="btn btn-info btn-xs" ng-click="medicalMsg(friendDetail.userId)"
                                    ng-if="currentUser.isMedicalAdmin || friendDetail.isMedicalAdmin">发消息
                            </button>
                        </td>
                    </tr>
                </table>
                <div class="row" style="margin:-10px 0;">
                    <div class="col-sm-4 text-left">
                        <small class="text-muted inline m-t-sm m-b-sm">
                            <span translate="common.showing"></span>
                            {{addFriend.count==0?0:(addFriend.pageNo-1)*addFriend.pageSize+1}} -
                            {{(addFriend.pageNo-1)*addFriend.pageSize+addFriend.thisPageSize}}
                            <span translate="common.of"></span>
                            {{addFriend.count}}
                            <span translate="common.items"></span>
                        </small>
                    </div>
                    <div class="col-sm-8 text-right text-center-xs">
                        <pagination ng-model="addFriend.pageNo" ng-change="selectPage()"
                                    total-items="addFriend.count" items-per-page="addFriend.pageSize"
                                    max-size="addFriend.selectPerNum" class="pagination-sm m-t-none m-b"
                                    boundary-links="true" rotate="false" previous-text="&lsaquo;"
                                    next-text="&rsaquo;" first-text="&laquo;" last-text="&raquo;"></pagination>
                    </div>
                </div>
            </div>
        </div>
    </div>
</script>

<script type="text/ng-template" id="medicalListModal.html">
    <div class="panel panel-default" style="margin-bottom:0;">
        <div class="bg-light lter b-b wrapper-sm">
            <button type="button" class="close" ng-click="cancel()"><span class="icon icon-close"
                                                                          aria-hidden="true"></span></button>
            <h1 class="m-n font-thin h3">
                <span class="font-bold" translate="">找医助</span>
            </h1>
        </div>
        <div class="wrapper-xs">
            <table class="table table-striped b-t b-light">
                <tr class="panel-heading">
                    <th><span class="font-bold" translate="common.number">No.</span></th>
                    <th ng-if="!isSmart"><span class="font-bold" translate="user.username">Username</span></th>
                    <th><span class="font-bold" translate="user.realname">Real Name</span></th>
                    <th ng-if="!isSmart"><span class="font-bold" translate="user.gender">gender</span></th>
                    <th ng-if="!isSmart"><span class="font-bold" translate="user.mobilephone">Mobile</span></th>
                    <th ng-if="!isSmart"><span class="font-bold" translate="user.hosp"></span></th>
                    <th><span class="font-bold" translate="common.operate">Operate</span></th>
                </tr>
                <tr ng-repeat="friendDetail in medicalList">
                    <td style="padding:2px 10px;vertical-align:middle">{{(addFriend.pageNo-1) * addFriend.pageSize +
                        $index + 1}}
                    </td>
                    <td ng-if="!isSmart" style="padding:2px 10px;vertical-align:middle">{{friendDetail.userName}}
                    </td>
                    <td style="padding:2px 10px;vertical-align:middle">{{friendDetail.realName}}</td>
                    <td ng-if="!isSmart" style="padding:2px 10px;vertical-align:middle"><span
                            translate="{{'user.gender.' + friendDetail.gender}}"></span></td>
                    <td ng-if="!isSmart" style="padding:2px 10px;vertical-align:middle">
                        {{friendDetail.mobile_Phone}}
                    </td>
                    <td ng-if="!isSmart" style="padding:2px 10px;vertical-align:middle">{{selectLang == 'English' ?
                        friendDetail._doctor._hosp.hosp_En_Name : friendDetail._doctor._hosp.hosp_Cn_Name}}
                    </td>
                    <td style="padding:2px 10px;vertical-align:middle">
                        <button class="btn btn-primary btn-xs"
                                ng-click="open({ templateUrl: 'views/system/user_detail.html?tmp=2'}, {{ friendDetail }} )">
                            详情
                        </button>
                        <button class="btn btn-success btn-xs" ng-click="addFriends(friendDetail.userId)"
                                ng-if="friendDetail.userId != currentUser.userId">加好友
                        </button>
                        <button class="btn btn-info btn-xs" ng-click="medicalMsg(friendDetail.userId)"
                                ng-if="friendDetail.userId != currentUser.userId">发消息
                        </button>
                    </td>
                </tr>
            </table>
        </div>
    </div>
</script>
